<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3">
            <?php echo $this->partial('_menu.phtml');?>
            <!--/.well -->
        </div>
        <!--/span-->
        <div class="span9">
            <div class="wrap">
                <div id="main-content">
                <div class="top-link"><a href="<?php echo $this->baseUrl() ?>/admin/mail/ajout">Ajout</a></div>
                <?php echo $this->partial('_message.phtml') ?>
                    <table>
                        <thead>
                            <tr>
                                <th>Sujet</th>
                                <th>Date &amp; Heure de création</th>
                                <th></th>
                                <th>Date &amp; Heure d'envoi</th>
                                <th>Editer</th>
                                <th>Supprimer</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <td colspan="6">
                                    <?php if(count($this->paginator) > 1) :?>
                                        <?php echo $this->paginationControl($this->paginator, 'Sliding', '_pagination.phtml'); ?>
                                    <?php endif;?>
                                    <!-- End .pagination -->

                                    <div class="clear"></div>
                               </td>
                            </tr>
                        </tfoot>
                        <tbody>
                            <?php
                            foreach($this->paginator as $rs) :
                                $dtcreat = new DateTime($rs['dtcreat']);
                                $dtenvoi = new DateTime($rs['dtenvoi']);
                            ?>
                            <tr>
                                <td style="text-align:left"><?php echo stripslashes($rs['titre'])?></td>
                                <td style="text-align:left"><?php echo $dtcreat->format('d/m/Y') .' '. $rs['hrcreat'] ?></td>
                                <?php if ($rs['hrend'] != null) :?>
                                    <td align="right"><?php echo $this->image()->getMail(1, 'Message envoyé') ?></td>
                                    <td><?php echo $dtenvoi->format('d/m/Y') . " " . $rs['hrend'];?>
                                    <?php if($rs['currentnbr'] > 0):?>
                                        (<b><?php echo $rs['currentnbr'];?></b> personnes)</td>
                                    <?php else :?>
                                        </td>
                                    <?php endif;?>
                                <?php else :?>
                                    <?php if($rs['tosend'] == 0) :?>
                                        <td align="right">
                                            <a href="<?php echo $this->baseUrl('admin/mail/send') ?>/?id=<?php echo $rs['p_mailing'] ?>&num_vente=<?php echo $this->request()->getParam('num_vente', 0) ?>" class="delete-item">
                                                <?php echo $this->image()->getMail(0, 'Envoyer le message') ?>
                                            </a>
                                        </td>
                                        <td>A envoyer</td>
                                    <?php else : ?>
                                        <td colspan="2">En cours d'envoi (<b><?php echo $rs['currentnbr']?></b> déjà envoyés)</td>
                                    <?php endif;?>
                                <?php endif;?>
                                <td><a href="<?php echo $this->baseUrl() ?>/admin/mail/ajout/id/<?php echo $rs['p_mailing']?>"><img src="<?php echo $this->baseUrl()?>/images/pencil.png"></a></td>
                                <td><a href="<?php echo $this->baseUrl('admin/mail/delete-mail/id/' .$rs['p_mailing'])?>/page/<?php echo $this->page ?>" class="delete-item"><img src="<?php echo $this->baseUrl()?>/images/cross.png"></a></td>
                            </tr>
                            <?php endforeach ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <!--/row-->
        </div>
        <!--/span-->
    </div>
    <!--/row-->
</div>